<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
        console.log(navigator);
        if (navigator.onLine) {
            alert('能够上网')
        } else {
            alert('不能')
        }
    </script>
</body>
</html>
